package com.zyf.qa.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyf.qa.dao.ProblemDao;
import com.zyf.qa.pojo.Problem;
import com.zyf.qa.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "qa_")
public class ProblemServiceImpl extends ServiceImpl<ProblemDao, Problem> implements ProblemService {
    @Autowired
    ProblemDao problemDao;
@Cacheable(key = "#labelid")
    public PageInfo<Problem> findNewListByLabelId(String labelid, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Problem> newListByLabelId = problemDao.findNewListByLabelId(labelid);
        PageInfo<Problem> problemPageInfo = new PageInfo<>(newListByLabelId);
        return problemPageInfo;
    }
    @Cacheable(key = "#labelid")
    public PageInfo<Problem> findHotListByLabelId(String labelid, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Problem> newListByLabelId = problemDao.findHotListByLabelId(labelid);
        PageInfo<Problem> problemPageInfo = new PageInfo<>(newListByLabelId);
        return problemPageInfo;
    }
    @Cacheable(key = "#labelid")
    public PageInfo<Problem> findWaitListByLabelId(String labelid, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Problem> newListByLabelId = problemDao.findWaitListByLabelId(labelid);
        PageInfo<Problem> problemPageInfo = new PageInfo<>(newListByLabelId);
        return problemPageInfo;
    }
}
